#include <iostream>
#include <cstdio>
#include <QApplication>
#include <QDesktopWidget>
#include <QString>
#include "../common/ClientTCP.h"
#include "KeyPress.h"

using namespace std;

void center(QWidget &widget)
{
	int x, y;
	int screenWidth, screenHeight; 
	int width= 250;
	int height = 150;

	QDesktopWidget *desktop = QApplication::desktop();

	screenWidth = desktop->width();
	screenHeight = desktop->height();

	x = (screenWidth - width) / 2;
	y = (screenHeight - height) / 2;

	widget.setGeometry(x, y, widht, height);
	widget.setFixedSize(width, height);
}

int main(int argc, char **argv)
{ 
	ClientProtocol* p = new ClientTCP(0);

	if (p->connect("192.168.1.2") != -1)
	{
		printf("Connected to server\n");
	}


	QApplication app(argc, argv);

	KeyPress window;
	window.setProtocol(p);

	window.setWindowTitle("Key press");
	window.show();
	center(window);
	
	return app.exec();
}
